package com.easygoods.service;

import com.bestvike.stone.spring.exception.BusinessException;
import com.bestvike.stone.spring.exception.ErrorCode;
import com.bestvike.stone.spring.service.BaseService;
import com.easygoods.dao.MerchantInfoDao;
import com.easygoods.entity.MerchantInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

/**
 * Created by 许崇雷 on 2019-01-28.
 */
@Service
public class MerchantService extends BaseService {
    @Autowired
    private MerchantInfoDao merchantInfoDao;

    //获取商户信息
    public MerchantInfo getMerchantInfo(String merchantId) {
        Assert.hasText(merchantId, "merchantId can not be empty");
        MerchantInfo merchantInfo = this.merchantInfoDao.selectByPrimaryKey(merchantId);
        if (merchantInfo == null)
            throw new BusinessException(ErrorCode.ERROR_SERVER, "无效的商户");
        return merchantInfo;
    }
}
